package year2019.month08910;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @desc 描述
 * create on 2018/10/8 by watson
 */
public class MainTest02 {
    public static void main(String[] args){
        ArrayList<Long> numList = new ArrayList<>();
        numList.add(0L);
        for (Long k0=1L;k0<10;k0++) {
            numList.add(k0);
            for (Long k1 = 0L; k1 < 10; k1++) {
                if (k1 == k0) continue;
                numList.add(k0 * 10L + k1);
                for (Long k2 = 0L; k2 < 10; k2++) {
                    if (k2 == k1 || k2 == k0) continue;
                    numList.add(k0 * 100L + k1 * 10L + k2);
                    for (Long k3 = 0L; k3 < 10; k3++) {
                        if (k3 == k2 || k3 == k1 || k3 == k0) continue;
                        numList.add(k0 * 1000L + k1 * 100L + k2 * 10L + k3);
                        for (Long k4 = 0L; k4 < 10; k4++) {
                            if (k4 == k3 || k4 == k2 || k4 == k1 || k4 == k0) continue;
                            numList.add(k0 * 10000L + k1 * 1000L + k2 * 100L + k3 * 10L + k4);
                            for (Long k5 = 0L; k5 < 10; k5++) {
                                if (k5 == k4 || k5 == k3 || k5 == k2 || k5 == k1 || k5 == k0) continue;
                                numList.add(k0 * 100000L + k1 * 10000L + k2 * 1000L + k3 * 100L + k4 * 10L + k5);
                                for (Long k6 = 0L; k6 < 10; k6++) {
                                    if (k6 == k5 || k6 == k4 || k6 == k3 || k6 == k2 || k6 == k1 || k6 == k0) continue;
                                    numList.add(k0 * 1000000L + k1 * 100000L + k2 * 10000L + k3 * 1000L + k4 * 100L + k5 * 10L + k6);
                                    for (Long k7 = 0L; k7 < 10; k7++) {
                                        if (k7 == k6 || k7 == k5 || k7 == k4 || k7 == k3 || k7 == k2 || k7 == k1 || k7 == k0) {
                                            continue;
                                        }
                                        numList.add(k0 * 10000000L + k1 * 1000000L + k2 * 100000L + k3 * 10000L + k4 * 1000L + k5 * 100L + k6 * 10L + k7);
                                        for (Long k8 = 0L; k8 < 10; k8++) {
                                            if (k8 == k7 || k8 == k6 || k8 == k5 || k8 == k4 || k8 == k3 || k8 == k2 || k8 == k1 || k8 == k0) {
                                                continue;
                                            }
                                            numList.add(k0 * 100000000L + k1 * 10000000L + k2 * 1000000L + k3 * 100000L + k4 * 10000L + k5 * 1000L + k6 * 100L + k7 * 10L + k8);
                                            for (Long k9 = 0L; k9 < 10; k9++) {
                                                if (k9 == k8 || k9 == k7 || k9 == k6 || k9 == k5 || k9 == k4 || k9 == k3 || k9 == k2 || k9 == k1 || k9 == k0) {
                                                    continue;
                                                }
                                                numList.add(k0 * 1000000000L + k1 * 100000000L + k2 * 10000000L + k3 * 1000000L + k4 * 100000L + k5 * 10000L + k6 * 1000L + k7 * 100L + k8 * 10L + k9);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        ArrayList<Long> sqrtNumList = new ArrayList<>();

        Iterator<Long> iterator = numList.iterator();
        while (iterator.hasNext()){
            Long i = iterator.next();
            double sqrt = Math.sqrt(i);
            long isqrt = (long) sqrt;
            if (isqrt*isqrt == i){
                sqrtNumList.add(i);
            }
        }

        System.out.println(sqrtNumList.size());
        System.out.println(sqrtNumList);
    }

}
